//
//  NSDate+Extension.m
//  RedGrass
//
//  Created by wuyine on 2019/1/4.
//  Copyright © 2019年 hongcaosp. All rights reserved.
//

#import "NSDate+Extension.h"

@implementation NSDate (Extension)
+ (NSString *)dateWithTimeStamp:(NSString *)timeStampString withFormatter:(NSString *)formatterString {
    // iOS 生成的时间戳是10位
    NSTimeInterval interval =[timeStampString doubleValue] / 1000.0;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:formatterString];
    NSString *dateString = [formatter stringFromDate:date];
    return dateString;
}

+(NSString *)changeFormatWithDateString:(NSString *)date{
    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
    NSDate *currentDate = [dateFormatter dateFromString:date];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    //    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"Asia/Shanghai"]];
    NSString *dateStr=[dateFormatter stringFromDate:currentDate];
    return dateStr;
}
@end
